////////////////////////////////////////////////////////////////////////////
//	File Name: Rectify.h		Last modification at : 2010-12-01
//	Copyright CAD&CG Lab
//
//	Author:      Ming Zeng
//	Email :      zengming@cad.zju.edu.cn
//
//	Description : This Module implement various algorithms of Rectification
//
//  Reference:
//  [1] A compact algorithm for rectification of stereo pairs
//
//	Revision History: 
//
//
////////////////////////////////////////////////////////////////////////////

#pragma once
#include "cv.h"

namespace NS_RECTIFICATION
{
	/////////////////////////////////////////////////////
	// Function Name: Rectify_Simple
	// Description: implementation of [1]
	// Notes:Rot0, Rot1 are 3*3 matrixs, stored as arrays, which are in row first order
	//       Intri0 and Intri1 are 3*3 matrixs, stored as arrays, which are in row first order
	//		 Trans0, Trans1 are 3*1 vectors, stored as arrays
	//       P0 and P1 are 3*4 matrixs, they are similar with Rot0 on storing style.
	/////////////////////////////////////////////////////
	void Rectify_Simple(/*IN*/const float* Rot0, /*IN*/ const float* Trans0, 
		/*IN*/const float* Intri0, 
		/*IN*/const float* Rot1, /*IN*/ const float* Trans1,
		/*IN*/const float* Intri1,
		/*OUT*/float* P0, /*OUT*/float* T0, 
		/*OUT*/float* P1, /*OUT*/float* T1);

	void Rectify_Simple( /*IN*/const CvMat* rotMat0, /*IN*/ const CvMat* transMat0, 
		/*IN*/const CvMat* intriMat0, 
		/*IN*/const CvMat* rotMat1, /*IN*/ const CvMat* transMat1,
		/*IN*/const CvMat* intriMat1,
		/*OUT*/CvMat* ProjNew0, /*OUT*/CvMat* TransformMat0, 
		/*OUT*/CvMat* ProjNew1, /*OUT*/CvMat* TransformMat1);

	void Rectify_Simple( /*IN*/const float* Rot0, /*IN*/ const float* Trans0, 
		/*IN*/const float* Intri0, 
		/*IN*/const float* Rot1, /*IN*/ const float* Trans1,
		/*IN*/const float* Intri1,
		/*OUT*/CvMat* ProjNew0, /*OUT*/CvMat* TransformMat0, 
		/*OUT*/CvMat* ProjNew1, /*OUT*/CvMat* TransformMat1);

	/////////////////////////////////////////////////////
	// Function Name: Rectify_Simple2
	// Description: implementation of [1]
	// Notes:The storing style are the same with what of Rectify_Simple
	/////////////////////////////////////////////////////
	void Rectify_Simple2(/*IN*/const float* POld0, /*IN*/ const float* POld1, 
		/*OUT*/float* PNew0, /*OUT*/float* PNew1 );


}